package search.binarysearch;

/**
 * @author XY
 * @version 1.0.0
 * @ClassName LC367.java
 * @createTime 2025年07月22日 19:52:00
 */
public class LC367 {
    public static boolean isPerfectSquare(int num) {
        int l = 0, r = num;
        while (l <= r) {
            int mid = l + (r-l)/2;
            long longMid = mid * mid;
            if (longMid == num) {
                return true;
            } else if (longMid < num) {
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(isPerfectSquare(2147483647));
    }
}
